package org.manon.json.meta;

import java.lang.reflect.Method;

/**
 * @author <a href="mailto:jacques.militello@gmail.com">Jacques Militello</a>
 */
public final class MetaPropertyAssociation extends MetaProperty {

	public MetaPropertyAssociation(String name, String label, Method method) {
		super(MetaPropertyType.ASSOCIATION,name, label, method);
	}

	/**
	 * @see java.lang.Comparable#compareTo(java.lang.Object)
	 */
	public int compareTo(MetaProperty otherProperty) {
		
		if (otherProperty instanceof MetaPropertyAssociation) {
			return getLabel().compareTo(otherProperty.getLabel());
		}
		
		if (otherProperty instanceof MetaPropertySingleValue) {
			return 1;
		}
		
		// other property is a collection
		return -1;
	}

	/**
	 * @see org.manon.json.meta.MetaProperty#accept(org.manon.json.meta.MetaPropertyVisitor)
	 */
	@Override
	public void accept(MetaPropertyVisitor visitor) {
		visitor.visit(this);
	}
	
}